package com.worldwizards.smut.serialization;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;

public class BinaryParser {
	DataInputStream _dis;
	
	public BinaryParser(BufferedInputStream bis){
		_dis = new DataInputStream(bis);
	}
	
	public byte peekByte() throws IOException{
		_dis.mark(1);
		byte b = (byte) _dis.read();
		_dis.reset();
		return b;
	}
	
	public byte readByte() throws IOException{
		return (byte) _dis.read();
	}
	
	public int readInt() throws IOException{
		return _dis.readInt();
	}
	
	public String readUTF() throws IOException {
		return _dis.readUTF();
	}

	public long readLong() throws IOException {
		return _dis.readLong();
	}

	public void mark() {
		_dis.mark(0);
	}
	
	public void rewind(){
		try {
			_dis.reset();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public short readShort() throws IOException {
		return _dis.readShort();
	}

	public char readChar() throws IOException {
		return _dis.readChar();
	}

	public double readDouble() throws IOException {
		return _dis.readDouble();
	}

	public float readFloat() throws IOException {
		return _dis.readFloat();
	}

	public boolean readBoolean() throws IOException {
		return _dis.readBoolean();
	}
	
	
}